package com.example.demo.controller;

import com.example.demo.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @Author: huanggaotao
 * @Description:
 * @Date: Created in 17:06 2021/7/28
 * @Modified By:
 */
//在这里后台 请求数据代码 最好跟  页面跳转代码 分隔开，习惯要养好


@Controller
public class IndexController {

    @Autowired
    ContentService contentService;


    @GetMapping({"/","/index"})
    public String index(){
        return "index";
    }


    @GetMapping("/search/{keyword}/{pageNo}/{pageSize}")
    @ResponseBody
    public List<Map<String, Object>> search(@PathVariable("keyword") String keyword,
                         @PathVariable("pageNo")int pageNo,
                         @PathVariable("pageSize")int pageSize) throws IOException {
        //高亮版本
        return contentService.searchHighlightPage(keyword, pageNo, pageSize);
    }
}
